package pack03_ovid_partitioner;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

import java.util.HashMap;

/**
 * @author lilulu
 * @date 2023/2/11 1:11
 */
public class CovidBeanPartitioner extends Partitioner<CovidBean, NullWritable> {
    /*static HashMap<String,Integer> stateMap= new HashMap<>();
    static{
        stateMap.put("Alabama", 0);
        stateMap.put("Arkansas", 1);
        stateMap.put("California", 2);
        stateMap.put("Florida", 3);
        stateMap.put("Indiana", 4);
    }*/
    @Override
    public int getPartition(CovidBean covidBean, NullWritable nullWritable, int i) {
        return (covidBean.getState().hashCode() & 2147483647) % i;
        /*String state = covidBean.getState();
        return stateMap.get(state);*/
    }
}
